<?php defined('InShopNC') or exit('Access Invalid!');?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="HandheldFriendly" content="true"/>
    <meta name="MobileOptimized" content="320"/>
    <script type="text/javascript" src="<?php echo TEMPLATES_PATH; ?>/js/config.js?v=<?php echo VERSION; ?>"></script>
    <script type="text/javascript"
            src="<?php echo TEMPLATES_PATH; ?>/js/hbuilder/common.js?v=<?php echo VERSION; ?>"></script>
    <script type="text/javascript"
            src="<?php echo TEMPLATES_PATH; ?>/js/hbuilder/pclick.js?v=<?php echo VERSION; ?>"></script>
    <script type="text/javascript">
        var ws = null, wo = null;
        var scan = null, domready = false;
        // H5 plus事件处理
        function plusReady() {
            if (!window.plus || !domready) {
                return;
            }
            ws = plus.webview.currentWebview();
            scan = new plus.barcode.Barcode('bcid');
            scan.onmarked = onmarked;
            ws.addEventListener('show', function () {
            scan.start();
        });
        }
        if (window.plus) {
            plusReady();
        } else {
            document.addEventListener("plusready", plusReady, false);
        }
        // 监听DOMContentLoaded事件
        document.addEventListener("DOMContentLoaded", function () {
            domready = true;
            plusReady();
        }, false);
        // 二维码扫描成功
        function onmarked(type, result, file) {
            result = result.replace(/\n/g, '');
            var url = url_match(result);
            if (url == '') {
                alert('该二维码不属于美财网，请重新扫描');
            } else {
                pclicked(url, 1);
            }
            back();
        }
        //匹配美财网网址
        function url_match(url) {
            var d;
            d = url.match(/goods-(\d+)\.html/);
            if ((d instanceof Array) && typeof d[1] == 'string') {
                return 'index.php?act=goods&goods_id=' + d[1];
            }
            d = url.match(/store-(\d+)\.html/);
            if ((d instanceof Array) && typeof d[1] == 'string') {
                return 'index.php?act=show_store&id=' + d[1];
            }
            return '';
        }
    </script>
    <style type="text/css">
        #bcid {width: 100%;position: absolute;top: 0px;bottom: 44px;text-align: center;}
        .tip {color: #FFFFFF;font-weight: bold;text-shadow: 0px -1px #103E5C;}
        footer {width: 100%;height: 44px;position: absolute;bottom: 0px;line-height: 44px;text-align: center;color: #FFF;}
        .fbt {width: 100%;height: 100%;background-color: #FFCC33;float: left;}
        .fbt:active {-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.5);box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.5);}
    </style>
</head>
<body style="background-color: #000000;">
<div id="bcid">
    <br/><br/><br/><br/><br/>
    <p class="tip">...载入中...</p>
</div>
<footer>
    <div class="fbt" onclick="back();">取　 消</div>
    <!--<div class="fbt" onclick="scanPicture();">从相册选择二维码</div>-->
</footer>
</body>
</html>